var ports = require("../../utils/ports.js")
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    member: {}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    wx.showToast({
      title: '加载中',
      icon: 'loading',
      mask: true
    })
    var req = {}
    var member = wx.getStorageSync('USER_MEMBER');
    that.setData({
      member: member
    })
    req.scene = wx.getStorageSync('USER_MEMBERID');
    req.page = app.defaultQrcodeUrl;
    req.publicNo = app.publicNo;
    ports.ModuleMember.getWeixinAppQrcode(req, that, res => {
      if (res.data.header.code == 0) {
        that.setData({
          myqrcodeUrl: res.data.body.url
        })
        let req = {}
        req.memberID = member.memberID;
        req.sortTypeCode = 2
        req.pageNumber = 99
        ports.ModuleMember.getMemberRecommendList(req, that, res => {
          wx.hideToast()
          that.setData({
            recommandTotal: res.data.body.data.total,
            recommandList: res.data.body.data.rows
          })
        })
      } else {
        wx.showToast({
          title: res.data.header.msg
        })
      }
    }, err => {

    })
  },
  //微信分享
  onShareAppMessage(res) {
    var memberID = wx.getStorageSync("USER_MEMBERID")
    var url = app.defaultShareUrl
    if (memberID) {
      url += "?memberID=" + memberID
    }
    return {
      title: app.defaultShareTitle,
      path: url,
      imageUrl: app.logoUrl
    }
  }
})